package com.work.demo.rabbitmq.utils;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;


public class RabbitUtils {
	private static ConnectionFactory connectionFactory = new ConnectionFactory();

	static {
		connectionFactory.setHost("114.55.105.70");
		connectionFactory.setPort(5672);//5672是RabbitMQ的默认端口号
		connectionFactory.setUsername("linya");
		connectionFactory.setPassword("linya");
		connectionFactory.setVirtualHost("/linyadata");
	}

	public static Connection getConnection() {
		Connection conn = null;
		try {
			conn = connectionFactory.newConnection();
			return conn;
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
}
